package com.cskaoyan.day03.generic5;

import com.cskaoyan.day03.generic2.MysteryBox;

/**
 * @author stone
 * @date 2022/01/29 10:19
 */
public class MysteryBox2<T> {
    int id;
    T value;

    public MysteryBox2() {
    }

    public MysteryBox2(int id, T value) {
        this.id = id;
        this.value = value;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public T getValue() {
        return value;
    }

    public void setValue(T value) {
        this.value = value;
    }

    //使用泛型时，类型要求是Exception的子类或Exception
    public static <T> T show(MysteryBox2<? extends Exception> mysteryBox2) {
        Exception value = mysteryBox2.getValue();
        return (T) value;
    }
}
